package com.way.capture.utils;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.way.capture.App;

public class Settings {
    public static final String NIGHT_MODE_KEY = "key_night_mode";
    public static final String VIDEO_SIZE_KEY = "key_video_size_percentage";
    public static final String VIDEO_QUALITY_KEY = "key_video_quality";
    public static final String VIDEO_FRAME_KEY = "key_video_frame";
    public static final String VIDEO_AUDIO_KEY = "key_record_audio";
    public static final String VIDEO_STOP_METHOD_KEY = "key_video_stop_method";
    public static final String SHOW_COUNTDOWN_KEY = "key_three_second_countdown";
    public static final String SHAKE_KEY = "key_use_atouch";
    public static final String SCREENSHOT_SOUND = "key_screenshot_sound";
    public static final String LONG_SCREENSHOT_AUTO = "key_long_screenshot_auto";
    private SharedPreferences mPreferences;

    private Settings() {
        mPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext());
    }

    public static Settings getInstance() {
        return Inter.SETTINGS;
    }

    public boolean isNightMode() {
        return mPreferences.getBoolean(NIGHT_MODE_KEY, true);
    }

    public void setNightMode(boolean isNightMode) {
        mPreferences.edit().putBoolean(NIGHT_MODE_KEY, isNightMode).apply();
    }

    public int getVideoSize() {
        return Integer.valueOf(mPreferences.getString(VIDEO_SIZE_KEY, "720"));
    }

    public int getVideoQuality() {
        return Integer.valueOf(mPreferences.getString(VIDEO_QUALITY_KEY, "4000000"));
    }

    public int getVideoFrame() {
        return Integer.valueOf(mPreferences.getString(VIDEO_FRAME_KEY, "24"));
    }

    public boolean isVideoAudio() {
        return mPreferences.getBoolean(VIDEO_AUDIO_KEY, true);
    }

    public boolean isVideoStopFloat() {
        return mPreferences.getBoolean(VIDEO_STOP_METHOD_KEY, true);
    }

    public boolean isVideoCountdown() {
        return mPreferences.getBoolean(SHOW_COUNTDOWN_KEY, true);
    }

    public boolean isAutoScroll() {
        return mPreferences.getBoolean(LONG_SCREENSHOT_AUTO, false);
    }

    public boolean isSoundEnabled() {
        return mPreferences.getBoolean(SCREENSHOT_SOUND, false);
    }

    public boolean isShakeEnabled() {
        return mPreferences.getBoolean(SHAKE_KEY, true);
    }

    private static class Inter {
        public static final Settings SETTINGS = new Settings();
    }
}
